﻿package frEngine.primitives
{
    import baseEngine.basic.*;
    import baseEngine.core.*;
    import flash.geom.*;
    import frEngine.core.*;
    import frEngine.loaders.particleSub.particleInstance.*;
    import frEngine.shader.filters.*;

    public class FrCube extends Mesh3D
    {
        private var _width:Number;
        private var _height:Number;
        private var _depth:Number;
        private var _segments:int;
        private var _surf:FrSurface3D;

        public function FrCube(param1:String)
        {
            super(param1, true, null);
            this._surf = new FrSurface3D(param1);
            this._surf.addVertexData(FilterName_ID.POSITION_ID, 3, false, null);
            this._surf.addVertexData(FilterName_ID.UV_ID, 2, false, null);
            this._surf.addVertexData(FilterName_ID.NORMAL_ID, 3, false, null);
            return;
        }// end function

        override public function dispose(param1:Boolean = true) : void
        {
            super.dispose(param1);
            this._surf.download();
            return;
        }// end function

        public function reinit(param1:RenderList, param2:Number = 10, param3:Number = 10, param4:Number = 10, param5:int = 1, param6 = null) : void
        {
            this.renderList = param1;
            this._segments = param5;
            this._depth = param4;
            this._height = param3;
            this._width = param2;
            if (!param6)
            {
                param6 = 10066329;
            }
            var _loc_7:* = new BoxParticle(this._width, this._height, this._depth, this._segments);
            this._surf.getVertexBufferByNameId(FilterName_ID.POSITION_ID).vertexVector = _loc_7.vertexVector;
            this._surf.indexVector = _loc_7.indexVector;
            _loc_7.clear();
            this.setSurface(0, this._surf);
            this.setMaterial(param6, Texture3D.MIP_NONE, "FrCube");
            bounds = new Boundings3D();
            bounds.max.setTo(param2 * 0.5, param3 * 0.5, param4 * 0.5);
            bounds.min.setTo((-param2) * 0.5, (-param3) * 0.5, (-param4) * 0.5);
            bounds.length = bounds.max.subtract(bounds.min);
            bounds.radius = Vector3D.distance(bounds.center, bounds.max);
            return;
        }// end function

        public function get segments() : int
        {
            return this._segments;
        }// end function

        public function get depth() : Number
        {
            return this._depth;
        }// end function

        public function get height() : Number
        {
            return this._height;
        }// end function

        public function get width() : Number
        {
            return this._width;
        }// end function

    }
}
